/*
Hermes Core: General Purpose Mobile Agent Platform
Copyright (C) 2006 UNICAM - Università degli Studi di Camerino

Group leaders: Flavio Corradini and Emanuela Merelli

Developers: Ezio Bartocci, Diego Bonura, Rosario Culmone,
Davide Lorenzoli, Leonardo Mariani, Francesca Piersigilli, 
Lorenzo Scortichini, Leonardo Vito.

GNU Lesser Public License

This library is free software; you can redistribute it 
and/or modify it under the terms of the GNU Lesser General 
Public License as published by the Free Software Foundation, 
version 2.1 of the License.

This library is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public 
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

Emanuela Merelli
Dipartimento di Matematica ed Informatica
Università di Camerino
via Madonna delle Carceri, 62032 Camerino, Italy
E.Mail: emanuela.merelli@unicam.it
*/
package hermesV2;

import java.io.Serializable;

/**
 * The address of a place.
 */
public class PlaceAddress implements Serializable {
  

	/**
	 * 
	 */
	private static final long serialVersionUID = 798176088310913240L;

	/** The internet address of the platform */
    private String ip;

    /** The port of the platform */
    private int port;
    
    /** The number of the mobile phone */
    private String phoneNumber;

    /**
     * Creates a new <code>PlaceAddress</code> with given host and port.
     *
     * @param ip host where the place is running.
     * @param port port used by the place.
      * @param numb phonenumber of the mobile phone.
     */
    public PlaceAddress(String ip, int port, String numb) {
        this.ip = ip;
        this.port = port;
        this.phoneNumber = numb;
    }


    /**
     * Creates a new <code>PlaceName</code> on localhost with a given port.
     *
     * @param port port used by the place.
     * @param numb phonenumber of the mobile phone
     */
    public PlaceAddress(int port, String numb) {
        ip = "127.0.0.1";
        this.port = port;
        phoneNumber = numb;
    }

    /**
     * Gets host name.
     *
     * @return host name.
     */
    public String getIp() {
        return ip;
    }
    
    /**
     * Gets port number.
     *
     * @return phone number.
     */
    public String getPhoneNumber() {
        return phoneNumber;
    }
    
    
    /**
     * Gets port number.
     *
     * @return port number.
     */
    public int getPort() {
        return port;
    }

    /**
     * Returns a string representation of the name.
     *
     * @return a string representation of the name.
     */
    public String toString() {
        return "ip: " + ip + " port: " + port;
    }
    
    
    /**
     * It returns true if the id specified below is equals to the current one.
     *
     * @param ident An <CODE>PlaceAddress</CODE>.
     *
     * @return A boolean.
     */
    public final boolean equals(Object ident) {
        boolean success;
    	if (this == ident) {
            success= true;
        }else{
        	success = this.toString().equals(ident.toString());
        }
        return success;
    }
}
